﻿@model Dexter.Web.Mvc.ViewModel.FrontEnd.BlogController.BlogIndexViewData
@{
    ViewBag.Title = "Post";
    Layout = "../Shared/_layout.cshtml";
}

@section head{
	<link rel="start" title="@Model.Post.Title" href="@Html.Raw(U.Post.Detail(Model.Post))" /> 
}

@section footer{
	<script type="text/javascript">
		$(document).ready(function () {

			SyntaxHighlighter.config.clipboardSwf = '/media/clipboard.swf';
			SyntaxHighlighter.all();

			$('#secondary-tabs').minitabs(333, 'slide');
		});
	</script>
}

@{Html.RenderPartial("_blogPostControl", Model.Post);}

@if(Model.ReleatedPost != null && Model.ReleatedPost.Result != null && Model.ReleatedPost.Result.Any())
{
	<fieldset>
			<legend><strong>Related Post</strong></legend>
			<div id="recent-posts" class="widget widget_recent_entries">
				<ul>
					@foreach (var related in Model.ReleatedPost.Result)
					{
						<li style="list-style-type: none">
							<a href="@Html.Raw(U.Post.Detail(related))"> @related.Title </a> (@related.PublishDate.ToShortDateString())
						</li>
					}
					
					@if(Model.ReleatedPost.Result.Count() < Model.ReleatedPost.TotalCount)
					{
						<li style="list-style-type: none">
							<a href="@Html.Raw(U.Post.RelatedPosts(Model.Post))">
								<strong>More related document (@(Model.ReleatedPost.TotalCount - Model.ReleatedPost.Result.Count()))</strong>
							</a>
						</li>
					}
				</ul>
			</div>
		</fieldset>
		<br />
}

<a title="feedback anchor" name="feedback" />
<div id="secondary-tabs">
	<ul class="menu">
		<li>
			<a class="current" href="#tab-1">
				<span>
					<span>Comments (@Model.Post.TotalComments)</span>
				</span>
			</a>
		</li>
		<li>
			<a href="#tab-2">
				<span>
					<span>Trackbacks (@Model.Post.TotalTrackback)</span>
				</span>
			</a>
		</li>
	</ul>

	<div id="tab-1">
	</div>

	<div id="tab-2">
		<ol id="trackbacks">
			@if(Model.Post.TrackBacks == null || !Model.Post.TrackBacks.Any())
			{
				<li class="comment">
					There is no TrackBack for this post.
				</li>
			}
			else
			{
				for(int i = 0; i < Model.Post.TrackBacks.Count(); i++) {
					var trackBack = Model.Post.TrackBacks[i];
	
					<li class="comment">
						<div class="wrap">
							<div class="avatar">
								<a class="gravatar">
									<img class="avatar" width="64" height="64" src="http://images.websnapr.com/?url=${trackBack.Url}&size=t&nocache=65" alt="pingback" />
								</a>
							</div>
							<div class="details regularcomment">
								<p class="head">
									<span class="info">
										<a href="#comment-@i">#@(i+1)</a> da
										<a href="@trackBack.Url" rel="nofollow" target="_blank">
											@trackBack.Url
										</a>
									</span>
								</p>
								<div class="text">
									<div id="trackbackbody-@i">
										<p>
											@trackBack.Title
										</p>
									</div>
								</div>
							</div>
						</div>
					</li>
				}	
			}
		</ol>
	</div>
</div>

@Html.TrackBackRdf(Model.Post)